package com.example.castday1.test;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.example.castday1.mapper.UserMapper;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

/**
 * @Author : 徐闯 mpcast
 * @Date : 2021-05-23 03:05:35
 * @Description :
 **/
@RunWith(SpringRunner.class)
@SpringBootTest
public class D_TestCondition {
    @Autowired
    private UserMapper userMapper;
    //根据姓名和邮箱模糊查询用户信息
    @Test
    public void dynamicSqlCast(){
        String name = " ";
        String email = "xx";
        userMapper.selectList(new QueryWrapper()
                .like(StringUtils.isNotBlank(name),"name",name)
                .like(StringUtils.isNotBlank(email),"email",email));
    }
}
